#include<bits/stdc++.h>
using namespace std;
int n,r,vis[10],a[10];
void dfs(int x,int sum){
	if(x==n+1){
		if(--r==0){
			for(int i=1;i<=n;++i) cout<<a[i]<<' ';
			exit(0);
		}return;
	}
	for(int i=1;i<(x==1?n+1:min(n+1,sum));++i)if(!vis[i]){
		vis[i]=1;
		a[x]=i;
		dfs(x+1,sum+i);
		vis[i]=0;
	}
}
int main(){
	freopen("permutation.in","r",stdin);
	freopen("permutation.out","w",stdout);
	cin>>n>>r;
	dfs(1,0);
	return 0;
}

